from django import forms
from .models import *


class RepoForm(forms.ModelForm):
    class Meta:
        model = Repo
        exclude = ()
        fields = ('name', 'no', 'price_per_100g_1d')

    def clean(self):
        no = self.cleaned_data.get('no')
        if Repo.objects.filter(no=no):
            raise forms.ValidationError('仓库编号重复')
